28 #define __PROTOCOL_INCLUDE_ENDPOINT_ONLY_API__ 29 #include "Protocol_internal.h" 30 #undef __PROTOCOL_INCLUDE_ENDPOINT_ONLY_API__ 54 #define MSG_SET_DRIVER_VERSION 0x21 55 #define MSG_GET_DEVICE_INFO 0x22 57 #define MSG_CONSUMPTION_DEF_REQ 0xD0 58 #define MSG_CONSUMPTION_DEF_CNF 0xD1 60 #define MSG_CONSUMPTION_REQ 0xD2 61 #define MSG_CONSUMPTION_CNF 0xD3 63 #define MSG_BOARD_INFO_REQ 0xE0 64 #define MSG_BOARD_INFO_CNF 0xE1 65 #define MSG_PARA_STORE_REQ 0xE2 66 #define MSG_PARA_STORE_CNF 0xE3 67 #define MSG_PARA_FACTORY_RESET_REQ 0xE4 68 #define MSG_PARA_FACTORY_RESET_CNF 0xE5 70 #define MSG_ERROR_IND 0xF0 100 static void parse_payload(int32_t protocol_handle, uint8_t endpoint,
101 const uint8_t* payload, uint16_t payload_size);
171 static uint16_t protocol_read_helper_str_list(
const uint8_t *payload,
const size_t offset,
size_t *p_elements,
char ***ptr )
173 uint16_t increment = 0;
174 uint8_t elements = protocol_read_payload_uint8( &payload[0], (uint16_t)offset );
176 if( p_elements != NULL)
177 *p_elements = (size_t) elements;
181 char **pData = (
char **) malloc(
sizeof(
char**) * elements );
182 for(
int i = 0; i < elements; i++)
184 uint8_t len = protocol_read_payload_uint8( &payload[0], (uint16_t)offset + increment );
186 char* pTemp = (
char *) malloc(
sizeof(
char) * ( len + 1 ) );
187 memcpy(pTemp, &payload[offset + increment], len);
203 static int32_t parse_para_values_cnf(int32_t protocol_handle, uint8_t endpoint,
204 const uint8_t* payload, uint16_t payload_size)
206 uint8_t payloadId = protocol_read_payload_uint8(payload, 0);
211 if (consumption_def_cnf_cb)
217 uint16_t size = protocol_read_payload_uint16(&payload[0], offset);
227 consumption_def_cnf_cb(consumption_def_cnf_ctx, protocol_handle,
228 endpoint, &consumption_def);
244 if (consumption_cnf_cb)
251 uint16_t size = protocol_read_payload_uint16(&payload[0], offset);
252 offset +=
sizeof(uint16_t);
254 elements = (size_t) protocol_read_payload_uint8(&payload[0], offset);
255 offset +=
sizeof(uint8_t);
259 for(uint32_t i = 0; i < elements; i++)
262 pData->
index = protocol_read_payload_uint8(&payload[0], offset);
265 temp = protocol_read_payload_uint32(&payload[0], offset);
266 memcpy(&pData->
value, &temp,
sizeof(
float));
267 offset +=
sizeof(uint32_t);
268 size_t len = (size_t) protocol_read_payload_uint8(&payload[0], offset);
271 pData->
p_unit = (
char *)malloc(len + 1);
272 memcpy(pData->
p_unit, &payload[offset], len);
275 offset += (uint16_t)len;
286 consumption_cnf_cb(consumption_cnf_ctx, protocol_handle,
287 endpoint, &consumption);
290 for( uint32_t i=0; i< elements; i++)
303 if (board_info_cnf_cb)
307 board_info.
major_version = protocol_read_payload_uint8(&payload[0], offset);
309 board_info.
minor_version = protocol_read_payload_uint8(&payload[0], offset);
312 uint8_t len = protocol_read_payload_uint8(&payload[0], offset);
319 len = protocol_read_payload_uint8(&payload[0], offset);
322 memcpy(board_info.
description, &payload[offset], len);
327 board_info_cnf_cb(board_info_cnf_ctx, protocol_handle,
328 endpoint, &board_info);
338 if (para_store_cnf_cb)
342 para_store_cnf_cb(para_store_cnf_ctx, protocol_handle, endpoint, &data);
349 if (para_factory_reset_cnf_cb)
353 para_factory_reset_cnf_cb(para_factory_reset_cnf_ctx, protocol_handle, endpoint, &data);
359 printf(
"tjba: message id not found\n");
366 static void parse_payload(int32_t protocol_handle, uint8_t endpoint,
367 const uint8_t* payload, uint16_t payload_size)
372 if (parse_para_values_cnf(protocol_handle, endpoint,
373 payload, payload_size))
400 uint8_t cmd_message[1];
407 cmd_message,
sizeof(cmd_message));
414 uint8_t cmd_message[1];
421 cmd_message,
sizeof(cmd_message));
428 uint8_t cmd_message[1];
435 cmd_message,
sizeof(cmd_message));
441 board_info_cnf_cb = callback;
442 board_info_cnf_ctx = p_context;
448 para_factory_reset_cnf_cb = callback;
449 para_factory_reset_cnf_ctx = p_context;
455 para_store_cnf_cb = callback;
456 para_store_cnf_ctx = p_context;
463 uint8_t cmd_message[1];
470 cmd_message,
sizeof(cmd_message));
476 consumption_def_cnf_cb = callback;
477 consumption_def_cnf_ctx = p_context;
490 uint8_t cmd_message[1+
sizeof(uint32_t)];
494 offset += protocol_write_payload_uint32(cmd_message, offset, repeat_count);
499 cmd_message, offset);
505 consumption_cnf_cb = callback;
506 consumption_cnf_ctx = p_context;
#define MSG_CONSUMPTION_REQ
void ep_radar_base_board_consumption_def_cb(consumption_def_cnf_callback_t callback, consumption_def_cnf_ctx_t *p_context)
int32_t ep_radar_base_board_para_store_req(int32_t protocol_handle, uint8_t endpoint)
This file contains the API methods applicable generically to Industrial radar Baseboard based Demos.
void ep_radar_base_board_para_store_cb(para_store_cnf_callback_t callback, para_store_cnf_ctx_t *p_context)
#define MSG_BOARD_INFO_CNF
#define MSG_PARA_FACTORY_RESET_CNF
#define MSG_CONSUMPTION_DEF_REQ
void ep_radar_base_board_board_info_cb(board_info_cnf_callback_t callback, board_info_cnf_ctx_t *p_context)
This file defines the status codes of the radar endpoints.
#define MSG_BOARD_INFO_REQ
void ep_radar_base_board_para_factory_reset_cb(para_factory_reset_cnf_callback_t callback, para_factory_reset_cnf_ctx_t *p_context)
void(* board_info_cnf_callback_t)(board_info_cnf_ctx_t *p_context, int32_t protocol_handle, uint8_t endpoint, board_info_cnf_t *p_data)
#define EP_RADAR_ERR_MSG_SIZE_CORRUPT
int32_t protocol_send_and_receive(int32_t protocol_handle, uint8_t endpoint, const Endpoint_Definition_t *endpoint_definiton, const uint8_t *payload, uint16_t payload_size)
const char * ep_radar_get_error_code_description(uint16_t error_code)
int32_t ep_radar_base_board_is_compatible_endpoint(int32_t protocol_handle, uint8_t endpoint)
This function checks if an endpoint in a device is a Radar Baseboard endpoint.
void(* para_store_cnf_callback_t)(para_store_cnf_ctx_t *p_context, int32_t protocol_handle, uint8_t endpoint, para_store_cnf_t *p_data)
int32_t ep_radar_base_board_consumption_req(int32_t protocol_handle, uint8_t endpoint, uint32_t repeat_count)
#define MSG_CONSUMPTION_CNF
int32_t protocol_is_endpoint_compatible(int32_t protocol_handle, uint8_t endpoint, const Endpoint_Definition_t *endpoint_definiton)
consumption_t * p_consumption
size_t consumption_label_elements
char ** pp_consumption_labels
const Endpoint_Definition_t ep_RadarBaseBoard_definition
#define MSG_PARA_FACTORY_RESET_REQ
void ep_radar_base_board_consumption_cb(consumption_cnf_callback_t callback, consumption_cnf_ctx_t *p_context)
int32_t ep_radar_base_board_board_info_req(int32_t protocol_handle, uint8_t endpoint)
void(* consumption_def_cnf_callback_t)(consumption_def_cnf_ctx_t *p_context, int32_t protocol_handle, uint8_t endpoint, consumption_def_host_t *p_data)
This is the callback type executed on a parameter value confirmation event, triggered,...
void(* consumption_cnf_callback_t)(consumption_cnf_ctx_t *p_context, int32_t protocol_handle, uint8_t endpoint, consumption_cnf_t *p_data)
#define MSG_CONSUMPTION_DEF_CNF
int32_t ep_radar_base_board_consumption_def_req(int32_t protocol_handle, uint8_t endpoint)
This function is used to request the parameter values,.
int32_t ep_radar_base_board_para_factory_reset_req(int32_t protocol_handle, uint8_t endpoint)
#define MSG_PARA_STORE_CNF
#define MSG_PARA_STORE_REQ
void(* para_factory_reset_cnf_callback_t)(para_factory_reset_cnf_ctx_t *p_context, int32_t protocol_handle, uint8_t endpoint, para_factory_reset_t *p_data)